package com.lm.flink.log;

import com.lm.flink.entry.LogLevelCount;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction;
import org.apache.flink.util.Collector;

public class LogLevelWindowResult extends ProcessWindowFunction<Long, LogLevelCount, String, TimeWindow> {
    @Override
    public void process(String key, Context context, Iterable<Long> elements, Collector<LogLevelCount> out) {
        Long count = elements.iterator().next();
        out.collect(new LogLevelCount(key, count, context.window().getEnd()));
    }
}
